package com.spoto.oa.service.impl;

import java.sql.SQLException;
import java.util.List;

import com.spoto.oa.dao.EmployeeDAO;
import com.spoto.oa.dao.impl.EmployeeDAOImpl;
import com.spoto.oa.model.Employee;
import com.spoto.oa.service.EmployeeServ;
/**
 * 
 * @Project_name: OA
 * @Description: 员工管理模块的操作的具体实现
 * @Author: LinYiSong
 * @Version: 
 * @Date: 2010-9-25~2010-9-25
 */
public class EmployeeServImpl implements EmployeeServ {
	EmployeeDAO employeeDAO=new EmployeeDAOImpl();

	public void addEmployee(Employee employee) throws SQLException {
		employeeDAO.save(employee);

	}

	/**
	 * 删除员工
	 */
	public void deleteEmployee(Employee employee) {
		employeeDAO.delete(employee);
	}


	public void updateEmployee(Employee employee) {
		employeeDAO.update(employee);
	}

	public List<Employee> searchByName(String name) {
		List<Employee> list=employeeDAO.selectByName(name);
		
		
		return list;
	}

	public List<Employee> searchByUserName(String username) {
		return employeeDAO.selectByUsername(username);
	}

	/**
	 * 根据员工名取得员工信息
	 */
	public Employee getByUserName(String username) {
		return employeeDAO.getByUsername(username);
	}
	
	
	/**
	 * 取得所有的员工信息
	 */
	public List<Employee> getAllEmployees() {
		
		return employeeDAO.getAll();
	}

	/**
	 * 添加发生冲突的员工数据
	 * @throws SQLException 
	 */
	public void addEmployeeConfict(Employee e) throws SQLException {
		employeeDAO.saveConfict(e);
	}

	/**
	 * 取得冲突的数据
	 */
	public Employee getByUserNameConfict(String username) {
		
		return employeeDAO.getByUsernameConfict(username);
	}

	public void deleteEmployeeConfict(Employee employee) {
		employeeDAO.deleteConfict(employee);
	}

	/**
	 * 取得所有冲突的员工信息
	 * @return
	 */
	public List<Employee> getAllEmployeesConfict() {
		return employeeDAO.getAllConfict();
	}

	public void deleteEmployeeByUsername(String username) {
		employeeDAO.deleteByUsername(username);
		
	}
	/**
	 * 根据qq模糊查询
	 * @param qq
	 * @return
	 */
	public List<Employee> searchByQq(String qq) {
		return employeeDAO.getByQq(qq);
	}
	/**
	 * 根据手机号模糊查询
	 * @param cell
	 * @return
	 */
	public List<Employee> searchByCell(String cell) {
		return employeeDAO.getAllByCell(cell);
	}

	/**
	 * 修改用户密码
	 */
	public void editPsw(String username, String psw) {
		employeeDAO.updatePsw(username, psw);
	}
	

}
